/* ===========================================================================
 *
 *       Filename:  inputmethod_manager.h
 *
 *    Description:  inputmethod_manager, abstract, qt
 *
 * - Mode: 644
 * - NOTE. NOT use "dos"
 * - Updated: 2015-04-26 16:49:50
 *
 *        Version:  1.0.0
 *        Created:  2015-04-22
 *       Revision:  1.0.0
 *       Compiler:  g++
 *
 *         Author:  Yui Wong, email: yuiwong@126.com
 *   Organization:  ""
 *        License:  LGPLv3
 *
 *  This file is part of portable-inputmethod.yw.
 *
 *  portable-inputmethod.yw
 *  is free software: you can redistribute it
 *  and/or modify it under the terms of the GNU General Public License as
 *  published by the Free Software Foundation, either version 3 of the
 *  License, or (at your option) any later version.
 *
 *  portable-inputmethod.yw
 *  is distributed in the hope that it will be
 *  useful, but WITHOUT ANY WARRANTY; without even the implied warranty of
 *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 *  GNU General Public License for more details.
 *
 *  You should have received a copy of the GNU General Public License along
 *  with portable-inputmethod.yw.
 *  If not, see <http://www.gnu.org/licenses/>.
 *
 * ===========================================================================
 */


#if !defined(_INPUTMETHOD_MANAGER_H_)
#define _INPUTMETHOD_MANAGER_H_ (1)


#if !defined(ID_QT_VERSION)
#	error "ID_QT_VERSION NOT defined"
#endif

#if (ID_QT_VERSION < 0x050000)
#	include <QtGui/QWidget>
#else
#	include <QtWidgets/QWidget>
#endif


/*
 * ===========================================================================
 * class inputmethod_manager
 * ===========================================================================
 */
class inputmethod;
class inputmethod_manager {
friend class inputmethod;

/*
 * some public field limit type
 */
public: typedef enum _click_state_t {
	/*
	 * click state
	 */
	click_state_press = 0,
	click_state_move,
	click_state_release,
	click_state_choose,/* selecting */
} click_state_t;

public: typedef enum _errno_t {
	/*
	 * errno
	 */
	errno_no_err = 0, /* no error */
	errno_no_method_created = 1, /* no method created yet */
	/*
	 * xyb part
	 */
	errno_zz_create_lib_fail, /* call zz_create_lib fail */

	/*
	 * zinnia part
	 */
	errno_zinnia_open_fail, /* call zinnia_recognizer_open fail */
} errno_t;


/*
 * INTERFACE(S)
 */
public: inputmethod * method(QWidget * focus,
	const char * conf = 0, QWidget * parent4method = 0);
public: void method_release(bool no_bond = false);
protected: static void method_released(void);
private: static bool method_no_bond;


/*
 * inputmethod_manager and ~inputmethod_manager
 * for child only
 */
protected: inputmethod_manager(void);
/* PROTECTED FOR INHERIT ONLY */
protected: virtual ~inputmethod_manager(void) = 0;

/* yes, have to implement this in the child */
private: virtual inputmethod * create_method(QWidget * focus,
	const char * conf = 0, QWidget * parent4method = 0) = 0;

/*
 * always a method alive
 */
private: static inputmethod * _method;
}; /* class inputmethod_manager */
/*
 * ===========================================================================
 * end of class inputmethod_manager
 * ===========================================================================
 */


#endif /* !defined(_INPUTMETHOD_MANAGER_H_) */
/*
 * end of file inputmethod_manager.h
 */
